﻿<Page:BasePage
    xmlns:Page="clr-namespace:Tfs.OnTheRoad.Pages"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:Mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"    
    xmlns:Controls="clr-namespace:Tfs.OnTheRoad.Controls"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
	x:Class="Tfs_OnTheRoad.WorkitemDetailsPage"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait" Orientation="Portrait" ApplicationBarButtons="Refresh,About,Back" 
	shell:SystemTray.IsVisible="True">
    <!--Enabling Page Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Controls:HeaderControl Grid.Row="0"  x:Name="HeaderControlPage" NavigationPath="Work Item Details"></Controls:HeaderControl>
        <!--Pivot Control-->
        <controls:Pivot Grid.Row="1">
            <!--Pivot item one-->
            <controls:PivotItem Header="General">
                    <ScrollViewer Margin="10,0,10,0">
                        <StackPanel ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Id}"  Style="{StaticResource DetailsHeaderID}" Margin="8,0" TextWrapping="Wrap" />
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> - </TextBlock>
                            <TextBlock Text="{Binding Type}"  Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="1" Style="{StaticResource DetailsHeaderID}" Margin="8,0" TextWrapping="Wrap"/>
                        </StackPanel>
                        <TextBlock Text="{Binding Title}" Grid.Column="1" VerticalAlignment="Top" Grid.Row="0" Grid.RowSpan="2" Style="{StaticResource DetailsHeaderText}" Margin="10,10,10,0" TextWrapping="Wrap"/>
                        <StackPanel Visibility="{Binding Description, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Description"  Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding Description}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap" />
                            </StackPanel>
                        <StackPanel Visibility="{Binding State, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="State"  Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding State}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding AreaPath, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Area"  Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding AreaPath}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding IterationPath, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Iteration" Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding IterationPath}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding CreatedBy, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Created By" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding CreatedBy}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding AssignedTo, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Asigned To" Foreground="{StaticResource PhoneAccentBrush}"  Grid.Column="0" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" />
                                <TextBlock Text="{Binding AssignedTo}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding Reason, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Reason" Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding Reason}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding StackRank, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Stack Rank" Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding StackRank}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding Priority, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Priority" Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding Priority}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding Severity, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Severity" Foreground="{StaticResource PhoneAccentBrush}"  Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding Severity}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding Revision, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Revision" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding Revision}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding CreatedDate, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Created Date" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding CreatedDate}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding ChangedBy, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Changed By" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  Height="27" VerticalAlignment="Top" />
                                <TextBlock Text="{Binding ChangedBy}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding ChangedDate, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Changed Date" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding ChangedDate}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding ResolvedBy, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Resolved By" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding ResolvedBy}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding FoundInBuild, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Found in Build" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding FoundInBuild}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap" />
                            </StackPanel>
                            <StackPanel Visibility="{Binding IntegratedInBuild, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Integrated in Build" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding IntegratedInBuild}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap"/>
                            </StackPanel>
                            <StackPanel Visibility="{Binding ReproSteps, Converter={StaticResource FieldHasValueVisibilityConverter}}">
                                <TextBlock Text="Steps to Reproduce:" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0"  />
                                <TextBlock Text="{Binding ReproSteps}" Style="{StaticResource PhoneTextTitle3Style}" FontSize="22" Margin="8,0" TextWrapping="Wrap" />
                            </StackPanel>
                        <HyperlinkButton Foreground="{StaticResource PhoneAccentBrush}" Grid.Row="20" Grid.ColumnSpan="2" Content="TFS Web Access" FontSize="22" HorizontalAlignment="Left" NavigateUri="{Binding WebEditorUrl}" TargetName="_blank" Margin="0,10" />
                        </StackPanel>
                    </ScrollViewer>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="Attachments">
                <Grid Margin="12,0,12,0" x:Name="AttachmentsGrid">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox x:Name="ItemsListBox" Grid.Row="0" ItemsSource="{Binding Items}" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <ListBox.Template>
                            <ControlTemplate TargetType="ListBox">
                                <ScrollViewer>
                                    <StackPanel>
                                        <ItemsPresenter/>
                                        <HyperlinkButton Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding LoadMoreResultsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HyperlinkButtonNotUnderlineStyle}">
                                            <Interactivity:Interaction.Triggers>
                                                <Interactivity:EventTrigger EventName="Click">
                                                    <Mvvm:EventToCommand Command="{Binding LoadMoreItems}"></Mvvm:EventToCommand>
                                                </Interactivity:EventTrigger>
                                            </Interactivity:Interaction.Triggers>
                                        </HyperlinkButton>
                                    </StackPanel>
                                </ScrollViewer>
                            </ControlTemplate>
                        </ListBox.Template>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Grid.Column="1" Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}"/>
                                    <TextBlock Text="{Binding Comment}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                                    <TextBlock Text="{Binding AttachedTime}" TextWrapping="Wrap" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                            <ColumnDefinition Width="*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Image Grid.Column="0" Width="28"  Source="/Images/Attachment.png" HorizontalAlignment="Center" VerticalAlignment="Center"></Image>
                                        <TextBlock Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Extension}" TextWrapping="Wrap" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                        <HyperlinkButton Foreground="{StaticResource PhoneAccentBrush}" Grid.Column="2" Content="Download" FontSize="22" HorizontalAlignment="Left" NavigateUri="{Binding Uri}" TargetName="_blank" Margin="0,10" />
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <TextBlock Grid.Row="0" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" Padding="10" TextWrapping="Wrap" FontSize="30" Text="{Binding NoResultsFoundMessage}"></TextBlock>
                    <toolkit:PerformanceProgressBar Height="20" x:Name="SearchProgressBar" Grid.Row="1" IsIndeterminate="True" Visibility="{Binding IsSearching, Converter={StaticResource BooleanToVisibilityConverter}}" />
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>
</Page:BasePage>